home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
util
/
text
/
tex.lha
/
MegaED
/
Trans
/
TeX.trans.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-03
|
2KB
|
111 lines
/*
** PasTeX.trans: Konvertiert PasTeX Fehlerausgaben für MegaEd
** von Sven Fischer, herpes@kawo2.rwth-aachen.de, 100% PD
*/
#include <exec/memory.h>
#include <dos/dos.h>
#include <dos/dostags.h>
#include <string.h>
int main(void)
{
const char *file1="T:MegaEdMake-ErrFile";
const char *file2="T:MegaEdMake-Errors";
BPTR con;
BPTR fileh;
char *old=NULL,*new=NULL;
char *off, *off2, *dest, *warn, *last;
LONG len;
short i;
BOOL errors=FALSE;
if(!(fileh=Open(file1,MODE_OLDFILE))) return;
Seek(fileh,0,OFFSET_END);
len=Seek(fileh,0,OFFSET_BEGINNING);
if(len)
{
if(!(old=(char*)AllocVec(len+1,MEMF_PUBLIC)))
{Close(fileh); return;}
if(Read(fileh,old,len)!=len)
{FreeVec(old); Close(fileh); return;}
}
Close(fileh);
if(!len) return;
old[len]=0;
if(!(new=(char*)AllocVec(len+1,MEMF_PUBLIC))) return;
off=old;
dest=new;
for(i=0;i<2;i++)
{
if(!(off=strchr(off,10))) goto esc;
off++;
}
for(;;)
{
warn=off;
off=strstr(off,"! ");
off2=strstr(warn,"full");
if(!off && !off2) break;
printf("off %ld off2 %ld\n",off,off2);
if(!off || (off2 && (ULONG)off2 < (ULONG)off))
{
off=off2-6; /* || diesen Teil auskommentieren */
*dest='W'; /* || um keine Warnings zu bekommen */
dest++; /* \/ (siehe readme) */
off2=strchr(off,10)+1;
for(;*off2==10;off2++);
off=strstr(off,"lines")+6;
for(;isdigit(*off);off++,dest++) *dest=*off;
*dest='/'; dest++;
*dest='1'; dest++;
*dest=10; dest++;
*off=0;
strcpy(dest,off2);
off2+=strlen(off2)+1;
dest+=strlen(dest);
*dest=10; /* /\ */
dest++; /* || */
off=off2; /* || */
}
else
{
*dest='E';
dest++;
off2=strchr(off,10)+3;
*(off2-3)=0;
off+=2;
for(;isdigit(*off2);off2++,dest++) *dest=*off2;
*dest='/'; dest++;
*dest='1'; dest++;
*dest=10; dest++;
strcpy(dest,off);
off+=strlen(off)+3;
dest+=strlen(dest);
*dest=10;
dest++;
}
errors=TRUE;
last=dest;
if(!*off) break;
}
esc:
if(errors)
{
if(fileh=Open(file2,MODE_NEWFILE))
{
len=(LONG)last-(LONG)new;
Write(fileh,new,len);
Close(fileh);
}
}
else DeleteFile(file2);
if(old) FreeVec(old);
if(new) FreeVec(new);
return(0);
}